<?
session_start();

	$username = $_SESSION['sess_Username'] ;
	$password = Null;
	$password = $_SESSION['sess_Password'] ;

echo '<br>username = '.$username;
echo '<br>password = '.$_SESSION['sess_Password'];
echo '<br>password = '.$password;

	$sess2_Name = $_POST[txtname];
	$sess2_LName = $_POST[txtlname];
	//$sess2_Position = $_POST[txtposition];	
	$sess2_Position = $_SESSION['sess_Position'];
	$sess2_Tel = $_POST[txttel];	
	$sess2_Email = $_POST[txtemail];
	

			   $src = $_FILES['userpicfile']['tmp_name'] ;
               $str_filename = $_FILES['userpicfile']['name'] ;
               $dest = "admin_pic_uploaded/$str_filename" ;
               if(move_uploaded_file ($src , $dest))
                        {   ?>
						<script language="javascript">
                        alert("Upload Completed");
                        </script>
	<? 					}
        										
	include "connectdb.php" ;
	$SQL2 = "select count(emp_username) from ag_employee where emp_username='$username'  and emp_password='$password' ;";
	$result = (mysql_db_query($dbname,$SQL2) or die ("ไม่สามารถแก้ไขไฟล์นี้ได้"));

	echo '<br> RESULT = '.$result;

if ($result ='1') {
	$SQL_UPDATE_EMP = "UPDATE ag_employee SET 
								  emp_name		= '$sess2_Name'
								, emp_lname		= '$sess2_LName'
								, emp_position	= '$sess2_Position'
								, emp_tel			= '$sess2_Tel'
								, emp_email		= '$sess2_Email' 
								where emp_username	= '$username' ;";
	$result = (mysql_db_query($dbname,$SQL_UPDATE_EMP) or die ("ไม่สามารถแก้ไขไฟล์นี้ได้"));
//	$result = mysql_db_query($dbname,$sqlUpdateEmp);

	echo '<br> RESULT xxxxx = '.$result;
	?>
    <script>
	   alert('แก้ไขข้อมูลเรียบร้อยแล้ว');
	</script>
    <?
	$_SESSION['sess_Name'] 		= $sess2_Name;
	$_SESSION['sess_LName'] 		= $sess2_LName;
	$_SESSION['sess_Position'] 	= $sess2_Position;	
	$_SESSION['sess_Tel'] 			= $sess2_Tel;	
	$_SESSION['sess_Email'] 		= $sess2_Email;
	}
else {
	?> 
     <script>
	   alert('error');
	   history.back();
	</script>
<?
   }
?>
 <meta http-equiv='refresh' content='0;URL=admin_adjpersonal.php'>  